
__kernel void matrix_cho(__global float * a) {
  int x = get_global_id(0); //identifiant ligne
  int y = get_global_id(1);  //identifiant colonne
  int n = get_global_size(0);
  
  int i = 0;
  for(i=0 ; i<n ; i++)
    {
      if (x==i && y==i)
	{
	  a[x*n+y] = sqrt(a[x*n+y]);
	}
      barrier(CLK_GLOBAL_MEM_FENCE);
      if(y==i && x>i)
	{
	  a[x*n+y] /= a[i*n+i];
	}
      barrier(CLK_GLOBAL_MEM_FENCE);
      if(x>i && y>i && y<=x)
	{
	  a[x*n+y] = a[x*n+y] - a[y*n+i]*a[x*n+i]; 
	}
      barrier(CLK_GLOBAL_MEM_FENCE);
    }	
}
